﻿using LxBasic;

namespace LxCore
{
    public partial class ZoneCFDFields
    {
        public WallDistance WallDistance;
        public ArrayScalar.BaseFace GammaCommon;
        public void CheckCreate_TurbBase()
        {
            if (Velocity != null && PhysicalModel.FlowType == FlowTypes.湍流)
            {
                CheckCreator.Instance(ref WallDistance);
                WallDistance.CheckCreate(Zone);
                //LxSim.Sim.Solvers.WallDistanceGroup.EquationsStorage.Add(WallDistance);

                CheckCreator.Instance(ref GammaCommon);
                GammaCommon.CheckCreate(Zone);
            }
            else
            {
                WallDistance = null;
                GammaCommon = null;
            }
        }
        public void SetParameter_TurbBase()
        {
            if (WallDistance == null) return;
            WallDistance.SetZone(PhysicalModel.ReferenceValue.MinWallDistanceLimit);
            foreach (var t in Zone.Bounds)
            {
                switch (ResHelper.GetCond(t).BoundType)
                {
                    case BoundTypes.壁面:
                        WallDistance.SetBound_Wall(t);
                        break;
                    case BoundTypes.对称面:
                    case BoundTypes.速度入口:
                    case BoundTypes.压力出口:
                        WallDistance.SetBound_Free(t);
                        break;
                    default:
                        LxLog.Error("未识别的边界类型");
                        break;
                }
            }
        }
    }
}
//if (WallDistance == null)
//{
//    WallDistance = new WallDistance();
//    WallDistance.CheckCreate(Zone);
//}
//if (GammaCommon == null)
//{
//    GammaCommon = new Value1FromArray1<double>();
//    GammaCommon.setParameter(new double[Zone.Faces.Length]);
//}
//public void SetWallDisPDE()
//{
//    ScalarOfLaplaceEquation walldis = WallDistance.MakePDECalulator();
//    SolverControl.WallDisGroup.PDEDistance.AddWallDisCal(WallDistance,  walldis);
//}
//walldis.setBoundary_fixValue(new ConstField(0), i1, t);
//walldis.setBoundary_fixFlux(new ConstField(0), i1, t);
// new ScalarOfSteadyDiffusion();
//walldis.CreateScalar(zone);
//walldis.setZone(new ConstField(1), new ConstField(1), new ConstField(0), 1);
//int i1 = 0;
//foreach (var t in zone.BoundThreads)
//{
//    switch (t.boundaryType)
//    {
//        case BoundaryTypes.流体壁面:
//            walldis.setBoundary_fixValue(new ConstField(0), i1, t);
//            break;
//        case BoundaryTypes.对称:
//        case BoundaryTypes.速度入口:
//        case BoundaryTypes.压力出入口:
//            walldis.setBoundary_fixFlux(new ConstField(0), i1, t);
//            break;
//        default:
//            MainViewModel.mainViewModel.log.AddWithTime("未识别的边界类型");
//            break;
//    }
//    i1++;
//}
//walldis.SetMultiGridAAtLast(zone.AMGSolver.MGLocal_A);
